/**
 * @author: xinmi
 * @date: 2020/11/2
 * @description:
 */
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

/**
 * Bean property details example
 *
 */
public class BeanPropertyDetails {
    public static void main(String[] args) {
        BeanInfo beanInfo = null;
        try {
            beanInfo = Introspector.getBeanInfo(Bean.class);
        } catch (IntrospectionException exception) {
            exception.printStackTrace();
        }
        PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
        for (int i = 0; i < descriptors.length; i++) {
            String propName = descriptors[i].getName();
            Class<?> propType = descriptors[i].getPropertyType();
            System.out.println("Property with Name: " + propName
                    + " and Type: " + propType);

        }

    }
}
